<?php

namespace app\admin\model;

use think\Model;


class WalletLog extends Model
{

    

    

    // 表名
    protected $name = 'shopro_user_wallet_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text'
    ];
    

    
    public function getTypeList()
    {
        return ['money' => __('Type money'), 'balance' => __('Type balance'), 'gold_bean' => __('Type bean'), 'shopping_score' => __('Type shopping'), 'commission' => __('Type commission'), 'score' => __('Type score'), 'tokens' => __('Type tokens')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
